
package cartagows.wsframework.wssecurity.policy.builders;

import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.builders.AssertionBuilder;

import cartagows.wsframework.wssecurity.policy.SP11Constants;
import cartagows.wsframework.wssecurity.policy.SPConstants;
import cartagows.wsframework.wssecurity.policy.WSSPolicyException;
import cartagows.wsframework.wssecurity.policy.model.AlgorithmSuite;

import javax.xml.namespace.QName;

public class AlgorithmSuiteBuilder implements AssertionBuilder {
        
    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
        AlgorithmSuite algorithmSuite = new AlgorithmSuite(SPConstants.SP_V11);
        
        OMElement policyElem = element.getFirstElement();
        
        try {
            algorithmSuite.setAlgorithmSuite(policyElem.getFirstElement().getLocalName());
        } catch (WSSPolicyException e) {
            throw new IllegalArgumentException(e);
        }
        
        return algorithmSuite;
    }
    
    public QName[] getKnownElements() {
        return new QName[] {SP11Constants.ALGORITHM_SUITE};
    }
}
